import server from './server.js'
import {showNotify} from "vant";

const serverValidateStatus = (status) => {
  if (status < 500){
    return status;
  }
  // 这里可以添加错误处理逻辑
  showNotify({ message: '网络错误，请刷新重试' });
  return status;
}

const serverGet = (path, params) => {
  return server.get(path, {
    params: params,
    validateStatus: serverValidateStatus,
  })
}

const serverPost = (path, data) => {
  return server.post(path, data, {
    validateStatus: serverValidateStatus,
  })
}

export default {
  get: serverGet,
  post: serverPost,
}